<template>
  <div :class="{ line: row === 1, lines: row > 1 }" :title="getTitle" :style="{ '--row': row }">
    {{ content }}
  </div>
</template>

<script setup name="Ellipsis" lang="ts">
type Props ={
  row?: number,
  hoverTip?: boolean,
  content?: string
}
//超出指定行数自动隐藏文字

const props = withDefaults(defineProps<Props>(), {
  row: 1,
  hoverTip: false,
  content: ""
})

const getTitle = (): string  =>{
  return props.hoverTip ? props.content : ""
}
</script>

<style lang="scss" scoped>
.line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lines {
  display: -webkit-box;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: var(--row);
  -webkit-box-orient: vertical;
}
</style>
